package com.dubbo.provider.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dubbo.api.entity.UserDO;
import com.dubbo.api.service.UserService;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: demo_dubbo
 * @description: 实现用户管理接口
 * @author: LQ
 * @create: 2020-08-06 14:20
 */
//dubbo注解，暴露服务
@Service
@org.springframework.stereotype.Service
public class UserServiceImpl implements UserService {
    @SuppressWarnings("serial")
    private List<UserDO> users = new ArrayList<UserDO>(){{
        add(new UserDO(1L, "熊大", "123"));
        add(new UserDO(2L, "熊二", "234"));
        add(new UserDO(3L, "熊三", "456"));
    }};

    @Override
    public UserDO findById( Long id) {
        return users.stream().filter(user -> user.getId().equals(id)).findFirst().get();
    }

    @Override
    public List<UserDO> listUser() {
        return users;
    }
}
